﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using LogTest.Logging;


namespace LogTest
{

    class Program
    {


        public delegate int OperationDelegate(int x, int y);
        public class Operator
        {
            private int _x, _y;
            public Operator(int x, int y)
            {
                this._x = x;
                this._y = y;
            }

            public void Operate(OperationDelegate del)
            {
                del(_x, _y);
            }
        }



        private static int Add(int x, int y)
        {
            int result = x + y;
            Console.WriteLine("x + y = {0}", result);
            return result;
        }


        private static int Sub(int x, int y)
        {
            int result = x - y;
            Console.WriteLine("x - y = {0}", result);
            return result;
        }


    
        static void DoWork()
        {
            Logger.Write(LogLevel.Debug, "nothing to do");
        }

        static void Main(string[] args)
        {

            Console.WriteLine("start to test the log wrapper class");


            OperationDelegate del = null;
            del += new OperationDelegate(Add);
            del += new OperationDelegate(Sub);

            Operator op = new Operator(5, 3);
            op.Operate(del);

            IList<string> list = null;

            
            try
            {
                Console.WriteLine(list.Count);
            }
            catch (Exception ex)
            {
                //Logger1.Trace(ex);
                //Logger.Write(LogLevel.Debug, "iioioio", ex);
            }


            //声明一含5个线程对象的数组
            const int num = 10000;
            Thread[] threads = new Thread[num];
            for (int i = 0; i < num; i++)
            {

                //将每一个线程都指向printer的PrintNumbers()方法

                threads[i] = new Thread(new ThreadStart(DoWork));

                //给每一个线程编号

                threads[i].Name = "thread id: " + i.ToString();
                Console.WriteLine(threads[i].Name.ToString());

            }

            //开始执行所有线程
            foreach (Thread t in threads) t.Start();



                Console.ReadKey();
        }
    }
}
